package com.local.common.constants;

/**
 * 订单状态：0.待支付 1.已支付 2.配货完成 3:出库成功 4.交易成功 -1.手动关闭 -2.超时关闭 -3.商家关闭
 */
public enum OrderStatusEnum {
    TO_PAY("待支付", 0),
    HAS_PAY("已支付", 1),
    GOODS_READY("配货完成", 2),
    GOODS_DELIVER("出库成功", 3),
    ORDER_COMPLETE("交易成功", 4),
    CLOSE_ADMIN("手动关闭", -1),
    CLOSE_TIMEOUT("超时关闭", -2),
    CLOSE_BUSINESS("商家关闭", -3),
    ;

    private Integer value;
    private String name;

    OrderStatusEnum(String name, Integer value){
        this.name = name;
        this.value = value;
    }

    public static OrderStatusEnum getOrderStatusEnumByStatus(int orderStatus) {
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
            if (orderStatusEnum.getValue() == orderStatus) {
                return orderStatusEnum;
            }
        }
        return TO_PAY;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
